<?php
$button = @$_POST ['submit'];
$search = @$_POST ['search']; 

if(!$button)
echo "Enter Item ID";
else
{
if(strlen($search)>=3)
echo "Item_ID length too long";
else{
echo "You searched for Item_ID: <b>$search</b> <hr size='1'></br>";
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "123";
$mysql_database = "rdb";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Opps some thing went wrong");

mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");

$search_exploded = explode (" ", $search);

foreach($search_exploded as $search_each)
{
@$x++;
if($x==1)
@$construct .="item.Item_ID  LIKE '%$search_each%'";
else
$construct .="AND item.Item_ID  LIKE '%$search_each%'";

}

/*$construct ="SELECT item.Name, warrenty claim.Warrenty period From item INNER JOIN warrenty claim ON item.Item_ID=warrenty claim.Item_ID WHERE $construct";*/
$construct="SELECT * FROM `warrenty claim`,item WHERE `warrenty claim`.Item_ID = item.Item_ID";

$run = mysql_query($construct);

$foundnum = mysql_num_rows($run);

if ($foundnum==0)
{
echo "Sorry, there are no matching result for";
}
 else
{
//echo "$foundnum results found !<p>";

while($runrows = mysql_fetch_assoc($run))
{

$Name = $runrows['Name'];
$SendDate = $runrows['Sdate'];
$Warrenty_period  = $runrows['Warrentperiod'];
$Problem_type = $runrows['Problem Type'];
$Categary_details = $runrows['Categary_details'];

echo " <b> Item Name = $Name<br>Send Date = $SendDate <br>Warrenty Period = $Warrenty_period<br>Problem Type = $Problem_type <br>Categary Details= $Categary_details <br><hr>";

}
}
}
}

?>
<form action='joinsearch.php' method='POST'>
<input type='text' size='30' name='search'>
<input type='submit' name='submit' value='Search by Item ID ' >
</form>